<?php

/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 * http://www.gnu.org/copyleft/gpl.html
 */
 


/**
 *  @file
 *  @Author Samuel Maura
 *  Display wiki page
 */


//ob_start();
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
session_start();
require_once("".$_SERVER['DOCUMENT_ROOT']."/xenix/controllers/authorize.php");
//ob_end_flush();

require_once("".$_SERVER['DOCUMENT_ROOT']."/xenix/views/html.php");
require_once("".$_SERVER['DOCUMENT_ROOT']."/xenix/lib/session/sessionUtils.inc");
require_once("".$_SERVER['DOCUMENT_ROOT']."/xenix/models/entries.php");
 
$entries = new Entries();
$display_title = $entries->displayTitle($_GET['title']);
$html = new Html();
$html->pageHeaderStart($display_title);
$html->mainStyle();
$html->Style('login');
$html->pageHeaderEnd();
$html->pageBodyStart();

if (isset($_SESSION['AUTHORIZED']) && ($_SESSION['AUTHORIZED'] == 1) &&  ($_SESSION['username'] != '') ){
  $html->displayLoginMenu($_SESSION['username']);
  $html->displayWikiMenuDetails($_GET['page_id'],$_GET['title'],$_GET['version']);
  
}

$html->displayLabel($display_title);

?>

<div class='hspacer'></div>
<div id='page_entry'>
<?
if (isset($_GET['action']) && ($_GET['action'] == 'history') ){
  $entry_array = $entries->getPageHistory($_GET['page_id']);
}
else{
  $entry_array = $entries->getPage($_GET['page_id']);
}

 if ( ($entry_array !== 0) && is_array($entry_array) ){
   foreach( $entry_array as $key => $value){
      echo "<p> ".$entry_array[$key]['content']."</p>";
      echo "<p> ID:  ".$entry_array[$key]['id']."</p>";
      //echo "<p> GROUP ID  ".$entry_array[$key]['group_id']."</p>";
      //echo "<p> RESTRICTION ID ".$entry_array[$key]['restriction_id']."</p>";
      echo "<p> CREATED ".$entry_array[$key]['created']."</p>";
      echo "<p> USER ID ".$entry_array[$key]['user_id']."</p>";
       echo "<p> AUTHOR IP ".$entry_array[$key]['author_ip']."</p>";
      echo "<p> REVISION  ".$entry_array[$key]['revision']."</p>";
      //echo "<p> MODIFIED ".$entry_array[$key]['last_modified']."</p>";
      echo "<div class='hspacer'></div>";
   }
 }
?>
</div>

<?
$html->pageFooter();
$html->pageBodyEnd();
?>